home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C20 / StreamIt.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  658 b   |  25 lines

  1. //: C20:StreamIt.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Iterators for istreams and ostreams
  7. #include "../require.h"
  8. #include <iostream>
  9. #include <fstream>
  10. #include <vector>
  11. #include <string>
  12. using namespace std;
  13.  
  14. int main() {
  15.   ifstream in("StreamIt.cpp");
  16.   assure(in, "StreamIt.cpp");
  17.   istream_iterator<string> init(in), end;
  18.   ostream_iterator<string> out(cout, "\n");
  19.   vector<string> vs;
  20.   copy(init, end, back_inserter(vs));
  21.   copy(vs.begin(), vs.end(), out);
  22.   *out++ = vs[0];
  23.   *out++ = "That's all, folks!";
  24. } ///:~
  25.